yosys と Tang Nano 9K
#Tang_Nano_9K
yosys を使った Tang Nano 9K のサンプルプログラムを動かしてみる。
Tang Nano 9K Examples
https://github.com/lushaylabs/tangnano9k-series-examples
リポジトリをクローンして、make load する。
code:sh
$ cd counter
$ make load
カウンタが動いた。
https://gyazo.com/068e01dcead9af03c22a00769f77a839
Makefileはこんな感じ。
code:Makefile
BOARD=tangnano9k
FAMILY=GW1N-9C
DEVICE=GW1NR-LV9QN88PC6/I5
all: counter.fs
# Synthesis
# (yosys で合成、counter.json を生成)
counter.json: counter.v
yosys -p "read_verilog counter.v; synth_gowin -top counter -json counter.json"
# Place and Route
# (nextpnr-gowin で配置、counter_pnr.json を生成)
counter_pnr.json: counter.json
nextpnr-gowin --json counter.json --write counter_pnr.json --freq 27 --device ${DEVICE} --family ${FAMILY} --cst ${BOARD}.cst
# Generate Bitstream
# (gowin_pack でビットストリームの生成、counter.fs を生成する)
counter.fs: counter_pnr.json
gowin_pack -d ${FAMILY} -o counter.fs counter_pnr.json
# Program Board
# (openFPGALoader でアップロード)
load: counter.fs
openFPGALoader -b ${BOARD} counter.fs -f
.PHONY: load
.INTERMEDIATE: counter_pnr.json counter.json
openFPGALoader の -f オプション
-f オプションはフラッシュへの書き込みが行われる。フラッシュの書き込み回数には限界があるので、開発中は -f オプション無しの方が良いかも。
制約ファイル
code:tangnano9k.cst
IO_LOC "clk" 52;
IO_PORT "clk" PULL_MODE=UP;
IO_LOC "led0" 10;
IO_LOC "led1" 11;
IO_LOC "led2" 13;
IO_LOC "led3" 14;
IO_LOC "led4" 15;
IO_LOC "led5" 16;
IO_LOC "btn1" 3;
IO_LOC "uart_tx" 17;
IO_PORT "uart_tx" IO_TYPE=LVCMOS33;
IO_LOC "uart_rx" 18;
IO_PORT "uart_rx" IO_TYPE=LVCMOS33;
メモ
counter_pnr.json に埋まってる seed を本物のファームウェアで置き換えたい。
ecpbramならぬ、gowinbram